package jgcp.master.scheduler;

import java.util.*; 

import jgcp.common.Task;

/*
 * set the tasks' priorities. Did by Dongwei Qi.
 */
public class AssignPriority {
	public Queue<Task> setTaskPriority(Queue<Task> sortedTaskList){
		Queue<Task> taskQueue=sortedTaskList;
		int listSize=taskQueue.size();
		for(int i=listSize-1;i>=0;i--){
			Task task=taskQueue.poll();
		    task.setPriority(task.getPriority()-i*2);
			taskQueue.add(task);
		}
		return taskQueue;	
	}
}
